{extend name="common/public" /}
{block name="content" /}
<div class="am-u-sm-12 am-u-md-12 am-u-lg-12" style="margin-top: 10px;">
    <div class="widget am-cf">
        <div class="widget-head am-cf">

            <div class="widget-title am-fl">修改支付密码</div>
            <div class="widget-function am-fr">
                <a href="javascript:;" class="am-icon-cog"></a>
            </div>
        </div>
        <div class="widget-body am-fr">
            <form class="am-form tpl-form-border-form tpl-form-border-br">
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        原支付密码 </label>
                    <div class="am-u-sm-9">
                        <input type="password" id="p" name="old_password" required="required"
                               class="tpl-form-input" placeholder="请填写原支付密码">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">新密码 </label>
                    <div class="am-u-sm-9"><input type="password"  id="p1" name="password" required="required" class="tpl-form-input" placeholder="请填写新支付密码">
                    </div>
                </div>
                <div class="am-form-group">
                    <label for="user-name" class="am-u-sm-3 am-form-label">
                        确认 </label>
                    <div class="am-u-sm-9">
                        <input type="password" id="p2" name="password" required="required"
                               class="tpl-form-input" placeholder="确认新支付密码">
                    </div>
                </div>

                <div class="am-form-group">
                    <div class="am-u-sm-9 am-u-sm-push-3">
                        <button type="button" onclick="add('{:url($type)}','form')"
                                class="am-btn am-btn-primary tpl-btn-bg-color-success">
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">

    var is_ajax = 1;
    function add(url,form) {

        if(!document.getElementById('p').value){
            layer.msg("请输入原密码")
            return;
        }
        if(!document.getElementById('p1').value){
            layer.msg("请输入新密码")
            return;
        }
        if(document.getElementById('p1').value !=document.getElementById('p2').value){
            layer.msg("两次密码不一致")
            return;
        }
        // if(is_ajax ==0) return;
        is_ajax =0;
        $.post(url,$(form).serialize(),function (res) {
            is_ajax =1;
            if(res.code!=0){
                layer.alert(res.msg,{icon:5})
            }else{
                layer.alert('操作成功!',{icon:6},function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    // parent.layer.close(index);//关闭当前页
                    window.parent.location.reload();
                })
            }
        },'json')
    }
</script>
{/block}
{extend}
